package br.com.fatecpg.fatecMobile;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;

public class NotificationService extends Service {

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	@Override
	public void onStart(Intent intent, int startId){
		super.onStart(intent, startId);
		Intent i = new Intent(this, ApplicationActivity.class);
		Bundle params = new Bundle();
		params.putInt("currentTab", 2);
		i.putExtras(params);
		PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
		Bundle eventsParams = intent.getExtras();
		Notification notification = new NotificationCompat.Builder(
				NotificationService.this)
				.setTicker("Evento agendado")
				.setContentIntent(pi)
				.setContentTitle("Evento agendado")
				.setContentText(eventsParams.getString("eventName")+" ("+eventsParams.getString("eventDate")+")").setSmallIcon(R.drawable.ic_launcher)
				.setAutoCancel(true).build();
		notification.defaults |= Notification.DEFAULT_LIGHTS;
		notification.defaults |= Notification.DEFAULT_SOUND;
		notification.defaults |= Notification.DEFAULT_VIBRATE;
		NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
		manager.notify(eventsParams.getInt("eventId"), notification);
	}
}
